import Vue from 'vue'
import Router from 'vue-router'
import Footer from '@/components/Footer'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  scrollBehavior (to,from,savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop
      }
      return {x:0,y:to.meta.savedPosition || 0}
    }
  },
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      components: {
        default: () => import('@/views/home/index.vue'),
        footer: Footer
      }
    },
    {
      path: '/detail/:id', 
      name: 'detail', 
      components: {
        default: () => import('@/views/detail/index.vue')
      }
    },
    {
      path: '/kind',
      name: 'kind',
      components: {
        default: () => import('@/views/kind/index.vue')
      }
    },
    {
      path: '/city',
      name: 'city',
      components: {
        default: () => import('@/views/city/index.vue')
      }
    },
    {
      path: '/weekgreat',
      name: 'weekgreat',
      components: {
        default: () => import('@/views/weekgreat/index.vue')
      }
    },
    {
      path: '/lucky',
      name: 'lucky',
      components: {
        default: () => import('@/views/lucky/index.vue')
      }
    },
    {
      path: '/eat',
      name: 'eat',
      components: {
        default: () => import('@/views/eat/index.vue')
      }
    },
    {
      path: '/baking',
      name: 'baking',
      components: {
        default: () => import('@/views/baking/index.vue')
      }
    },
    {
      path: '/register',
      name: 'register',
      components: {
        default: () => import('@/views/register/index.vue')
      }
    },
    {
      path: '/login',
      name: 'login',
      components: {
        default: () => import('@/views/login/index.vue')
      }
    },
    {
      path: '/soup',
      name: 'soup',
      components: {
        default: () => import('@/views/soup/index.vue')
      }
    },
    {
      path: '/vegetarian',
      name: 'vegetarian',
      components: {
        default: () => import('@/views/vegetarian/index.vue')
      }
    },
    {
      path: '/uno',
      name: 'uno',
      components: {
        default: () => import('@/views/uno/index.vue')
      }
		},
    {
      path: '/delicious',
      name: 'delicious',
      components: {
        default: () => import('@/views/delicious/index.vue')
      }
		},
    {
      path: '/chef',
      name: 'chef',
      components: {
        default: () => import('@/views/chef/index.vue'),
        footer: Footer
      }
    },
    {
      path: '/market',
      name: 'market',
      components: {
        default: () => import('@/views/market/index.vue'),
        footer: Footer
      },
      meta: {
        title: 'views',
        keepAlive: true
      }
    },
    {
      path: '/cart',
      name: 'cart',
      components: {
        default: () => import('@/views/cart/index.vue'), // 路由懒加载
      }
    },
		{
		  path: '/community',
		  name: 'community',
		  components: {
		    default: () => import('@/views/community/index.vue'),
		    footer: Footer
		  }
		},
    {
      path: '/user',
      name: 'user',
      components: {
        default: () => import('@/views/user/index.vue'),
        footer: Footer
      }
    },
    {
      path: '/attention',
      name: 'attention',
      components: {
        default: () => import('@/views/attention/index.vue')
      }
    },
    {
      path: '/newest',
      name: 'newest',
      components: {
        default: () => import('@/views/newest/index.vue')
      }
    }

  ]
})
